<?php
/**
 * Created by PhpStorm.
 * User: sofu
 */

namespace catcher\wxpush\src\Mediway;


class File
{
    /**
     * @var string 文件类型
     */
    private $mime;

    /**
     * @var string 键名
     */
    private $key;

    /**
     * @var boolean 是否解码为文件
     */
    private $isDecode;

    /**
     * @var boolean 是否以相同键名上传多张图片
     */
    private $isMulti;

    /**
     * @var string 文件名
     */
    private $name;

    /**
     * @var string 文件内容
     */
    private $data;

    /**
     * File constructor.
     * @param string $key
     * @param string $data
     * @param string $name
     * @param bool $isDecode
     * @param bool $isMulti
     * @param string $mime
     */
    public function __construct(string $key,string $data,string $name,bool $isDecode = false, $isMulti = false, string $mime = 'image/jpeg')
    {
        $this->mime = $mime;
        $this->key = $key;
        $this->isDecode = $isDecode;
        $this->isMulti = $isMulti;
        $this->name = $name;
        $this->data = $data;
    }

    /**
     * @return string
     */
    public function getMime(): string
    {
        return $this->mime;
    }

    /**
     * @param string $mime
     */
    public function setMime(string $mime)
    {
        $this->mime = $mime;
    }

    /**
     * @return string
     */
    public function getKey(): string
    {
        return $this->key;
    }

    /**
     * @param string $key
     */
    public function setKey(string $key)
    {
        $this->key = $key;
    }

    /**
     * @return bool
     */
    public function isDecode(): bool
    {
        return $this->isDecode;
    }

    /**
     * @param bool $isDecode
     */
    public function setIsDecode(bool $isDecode)
    {
        $this->isDecode = $isDecode;
    }

    /**
     * @return string
     */
    public function getName(): string
    {
        return $this->name;
    }

    /**
     * @param string $name
     */
    public function setName(string $name)
    {
        $this->name = $name;
    }

    /**
     * @return string
     */
    public function getData(): string
    {
        return $this->data;
    }

    /**
     * @param string $data
     */
    public function setData(string $data)
    {
        $this->data = $data;
    }

    /**
     * @return bool
     */
    public function isMulti(): bool
    {
        return $this->isMulti;
    }

    /**
     * @param bool $isMulti
     */
    public function setIsMulti(bool $isMulti)
    {
        $this->isMulti = $isMulti;
    }


    /**
     * 获取请求组装数据
     */
    public function getRequestData(){
        $file['mime'] = $this->getMime();
        $file['key'] = $this->getKey();
        $file['decode'] = $this->isDecode();
        $file['multi'] = $this->isMulti();
        $file['name'] = $this->getName();
        $file['data'] = $this->getData();
        return $file;
    }
}